Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CAPI-654 Add new concat/concat_lc actions to UpsertCondition used by … #64

Merged

Conversation

timatbw
Copy link

@timatbw timatbw commented Mar 5, 2024

…ConditionalUpsertProcessorFactory

This allows us to support updating a derived field when we do an atomic update of one of the contributing fields

…ConditionalUpsertProcessorFactory

This allows us to support updating a derived field when we do an atomic update of one of the contributing fields
SolrInputDocument onlyPreAndPost = new SolrInputDocument();
onlyPreAndPost.setField("maybe_prefix", "pre");
onlyPreAndPost.setField("maybe_suffix", "post");
assertTrue(condition.matches(null, onlyPreAndPost));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit subtle/weird that this will count as matching, but won't have actually set derived_field. I guess it might just need calling out a bit more clearly in a comment or something?

I wonder if we need a test to confirm that having multiple rules where the first rule does this behaves as we expect? e.g. only have optional fields for the first rule, but then confirm it does/doesn't interfere with later rules?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah matching doesn't necessarily imply it will take action, because the condition check is quite a complex boolean ((old.required OR new.required) AND (old.another OR new.another)). It's more of a pre-check for when it could conceivably be relevant

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would expect the conditional clauses for using this action would be should for all the contributing fields, and must_not for the derived field itself

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can add some tests for when there's multiple UpsertCondition in the overall configuration, to check that subsequent rules do/don't match depending on the outcome of an earlier concat action.

But the other issue, making the conditions accurately match only when the concat action will actually be able to set the derived field, I don't think we can achieve that with the current condition matching logic: it's not expressive enough to handle nested AND/OR conditions that we'd need. Effectively we'd need the condition matching to do the same old/new fallback logic that the action currently implements.

@timatbw
Copy link
Author

timatbw commented Mar 7, 2024

Added a bunch more tests, to check behaviour when multiple conditions are defined and when there's a mix of should clauses and must_not clauses (which is what I think we'll use in practice) and glad I did because it identified a subtle bug in rule matching logic. Worth reviewing just the 2nd commit.

@timatbw
Copy link
Author

timatbw commented Mar 8, 2024

I'm going to merge this as-is and then look at rebasing our stuff onto the new 8.11.3 branch, if it's a smooth transition

@timatbw timatbw merged commit 1a316c8 into BrandwatchLtd:bw_branch_8_11_2 Mar 8, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants